﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EnumDataSourceControlTest.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="include/CodeStyles.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            color: #0000FF;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h1>
            Salient.Web.UI.WebControls20</h1>
        <h2>
            EnumDataSource</h2>
                    <p>
            Author: Sky Sanders - <a href="mailto:sky.sanders@gmail.com">
            sky.sanders@gmail.com</a></p>

        <h5>
            Example usage:</h5>
        <ul>
            <li><a href="GridViewCellLookup.aspx">GridViewCellLookup.aspx</a> </li>
            <li><a href="KnownColors.aspx">KnownColors.aspx</a> </li>
        </ul>
        <h5>
            Description:</h5>
        <p>
            EnumDataSource provides a page bindable provider of <span class="style1">enum</span>
            information. Calls to GetView will return a collection of EnumValueInfo objects
            that represent the members of the enum specified as DataMember.
        </p>
        <p>
            Only one instance of EnumDataSource is required on a page.</p>
        <p>
            While there are many ways that enum information can be used the utility of EnumDataSource
            is most apparent in the case of grid cell ComboBox lookups for database fields that
            are based on numeric enumerations.</p>
        <p>
            In addition to returning the string constant Name for each value in the enum, EnumDataSource
            will parse any Description attribute present allowing for even more friendly labels
            for your enumerated values.</p>
        <p>
            EnumDataSource also exposes 2 utility methods for working with enums. For 
            example in parsing freeform user input for return to database or getting a 
            single description for binding to an ItemTemplate Label.</p>
        <h5>
            Usage:</h5>
        <ol>
            <li>Drop an instance of the EnumDataSource on the page.</li>
            <li>Bind any number of controls to it by assigning the full typename (e.g. 
                System.IO.FileAttribute) to the DataMember property of the bound control.<br />
                In a typical scenario in which your database field is numeric DataValueField 
                would be assigned to the IntegralValue field of the datasource and DataTextField 
                would be assigned to the Description or Name field of the datasource.<br />
                The inverse is also possible. If your database field is a textual representation 
                of the enum the DataValueField would be assigned to the Name field.</li>
        </ol>
        <p>
            &nbsp;</p>
        <h5>
            Installation:</h5>
        <p>
            Add it to your toolbox or drop it into your bin directory. The precompiled 
            binary is signed to it may be stored in the GAC if you so choose.</p>
        <p>
            &nbsp;</p>
        <div class='Code'>
            <div class='CodeSectionTop'>
            </div>
            <div class='CodeSectionBody'>
                <div style="font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt;
                    color: black; background: white; color: black; background-color: transparent;
                    /*white-space: pre; */  	width: 488px;">
                    <p style="margin: 0px;">
                        <span style="color: blue;">using</span> System;</p>
                    <p style="margin: 0px;">
                        <span style="color: blue;">namespace</span> Salient.Web.UI.WebControls</p>
                    <p style="margin: 0px;">
                        {</p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span style="color: green;">
                        </span><span style="color: gray;">&lt;summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span style="color: green;">
                            Represents an enumerated value</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span style="color: green;">
                        </span><span style="color: gray;">&lt;/summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">
                            class</span> <span style="color: #2b91af;">EnumValueInfo</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; {</p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> The typed enum value.</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span
                            style="color: #2b91af;">Enum</span> EnumValue { <span style="color: blue;">get</span>;
                        <span style="color: blue;">set</span>; }</p>
                    <p style="margin: 0px;">
                        &nbsp;</p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> Contents of optional System.ComponentModel.DescriptionAttribute.</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> If Description is not present, value is same as name.</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span
                            style="color: blue;">string</span> Description { <span style="color: blue;">get</span>;
                        <span style="color: blue;">set</span>; }</p>
                    <p style="margin: 0px;">
                        &nbsp;</p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> Integral value of described enum value. </span>
                    </p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> Will be byte,int,short or long.</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span
                            style="color: blue;">object</span> IntegralValue { <span style="color: blue;">get</span>;
                        <span style="color: blue;">set</span>; }</p>
                    <p style="margin: 0px;">
                        &nbsp;</p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> The name constant e.g. Enum.GetName()</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray;">///</span><span
                            style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span
                            style="color: blue;">string</span> Name { <span style="color: blue;">get</span>;
                        <span style="color: blue;">set</span>; }</p>
                    <p style="margin: 0px;">
                        &nbsp;</p>
                    <p style="margin: 0px;">
                        &nbsp;&nbsp;&nbsp; }</p>
                    <p style="margin: 0px;">
                        &nbsp;</p>
                    <p style="margin: 0px;">
                        }</p>
                    <p style="margin: 0px;">
                        &nbsp;</p>
                </div>
            </div>
            <div class='CodeSectionBottom'>
                <div class='Title'>
                    EnumValueInfo.cs</div>
            </div>
        </div>
      
        <%--<div class='Code'>
            <div class='CodeSectionTop'>
            </div>
            <div class='CodeSectionBody'>
            </div>
            <div class='CodeSectionBottom'>
                <div class='Title'>
                    C# // Snippet Title</div>
            </div>
        </div>--%>
    </div>
    </form>
</body>
</html>
